package kr.ac.kaist;

import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;

import android.util.Log;

public class CPUInfo {
	private double _dFrequency;
	private double _dUserPercentage;
	private double _dSystemPercentage;
	
	final private String CPU_FREQUENCY_PATH = "/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq";
	final private String TAG = "CPUInfo";
	
	public CPUInfo(){}
	
	public double getCPUFrequency(){
		FileReader fstream;
		try {
		      fstream = new FileReader(CPU_FREQUENCY_PATH);
		} catch (FileNotFoundException e) {
			Log.w(TAG, "Could not read cpu frequency file");
			return -1;
		}
		   
		BufferedReader in = new BufferedReader(fstream, 500);
		String line;
		
		try {
			line = in.readLine();
			return Integer.valueOf(line)/ 1000.0;
		} catch (IOException e) {
		}
		return 0.0;
	}
}
